<template>
	<view class="myAttention padding">
		<view class="cu-list menu-avatar" >
			<view class="cu-item" v-for="item in myAttentionList" :key="item.id" @click="goteacherdetail(item.id)">
				<view class="cu-avatar round lg">
					<image :src="item.image_url" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="content">
					<view class="text-grey">
						<view class="text-cut">{{item.name}}</view>
						<view class="cu-tag round bg-orange sm">讲师</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">
							{{item.desc}}
						</view>
					</view>
				</view>
				<view class="action" style="width: 140rpx;">
					<text class="bg-green text-xs" style="padding: 12rpx;border-radius: 18rpx;" @click="unAttention(item.id)">取消关注</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				myAttentionList:[]
			}
		},
		onLoad() {
			this.getMyAttentionData()
		},
		methods:{
			async getMyAttentionData(){
				let res = await this.$myRuquest({
					url:'/my_teacher/'
				})
				this.myAttentionList = res.data.results
			},
			unAttention(id){
				this.$myRuquest({
					url:`/click_teacher/${id}/`,
					method:'POST'
				}).then(res=>{
					this.getMyAttentionData()
				})
			},
			goteacherdetail(id){
				uni.navigateTo({
				    url: `../teacherdetail/teacherdetail?id=${id}`
				});
			},
		}
	}
</script>

<style>
</style>
